#pragma once

#include <vector>
#include <ctime>
#include <cstdlib>
#include <iostream>

typedef void(* task_t)();


void print()
{
    std::cout<<"打印日志任务"<<std::endl;
}
void downLode()
{
    std::cout<<"下载任务"<<std::endl;
}
void upLoad()
{
    std::cout<<"上传任务"<<std::endl;
}


class TaskManager
{
public:
    TaskManager()
    {
        srand(time(nullptr));

    };
    ~TaskManager(){};

    void pushTask(task_t task)
    {
        _tasks.push_back(task);
    }

    int code()
    {
        return rand()%_tasks.size();
    }

    void exe(int code)
    {
        if(code >= 0 && code < _tasks.size())
            _tasks[code]();
    }

private:
    std::vector<task_t> _tasks;
};